#!/bin/sh /etc/rc.common

START=99
STOP=99

USE_PROCD=1
CHIPSET=

configuration() {
	. /lib/functions/chirpstack-concentratord.sh
	configure "chirpstack-concentratord"
}

start_service() {
	[ "$(uci get chirpstack-concentratord.@global[0].enabled)" != "1" ] && return 1

	configuration

	procd_open_instance 
	procd_set_param command /usr/bin/chirpstack-concentratord-$CHIPSET -c /var/etc/chirpstack-concentratord/concentratord.toml -c /var/etc/chirpstack-concentratord/region.toml -c /var/etc/chirpstack-concentratord/channels.toml
	procd_set_param respawn 3600 5 -1
	procd_set_param file /etc/config/chirpstack-concentratord
	procd_close_instance
}

service_triggers() {
	procd_add_reload_trigger "chirpstack-concentratord"
}

reload_service() {
	stop
	start
}